local RSNG = RSNG
local C = RSNG.Classes

RSNG.Registries = {}

local Registry = AceOO.Class()

function Registry.prototype:init(name, class)
	Registry.parent.init(self)
	
	self.name = name
	self.class = class
	self.content = {}
	
	RSNG.Registries[name] = self
	RSNG["Register"..name] = function (_, name, class)
		return self:Register(name, class)
	end
end

function Registry.prototype:Register(name, class)
	assert(not self.content[name])
	assert(AceOO.inherit(class, self.class))
	self.content[name] = class
end

function Registry.prototype:Get(name)
	return self.content[name]
end

function Registry.prototype:Iterator()
	return next, self.content, nil
end

C.Registry = Registry

Registry:new("Filter", C.IFilter)
Registry:new("StatusBarInfo", C.IStatusBarInfo)
Registry:new("ButtonInfo", C.IButtonInfo)
Registry:new("UI", C.IUIElement)
